package com.smartaccounting.service;

import com.smartaccounting.dao.IncomeDAO;
import com.smartaccounting.model.Income;

import java.math.BigDecimal;
import java.sql.SQLException;
import java.time.LocalDate;
import java.util.List;

public class IncomeService {
    private IncomeDAO incomeDAO;

    public IncomeService() {
        this.incomeDAO = new IncomeDAO();
    }

    public boolean addIncome(Income income) throws SQLException {
        return incomeDAO.addIncome(income);
    }

    public boolean updateIncome(Income income) throws SQLException {
        return incomeDAO.updateIncome(income);
    }

    public boolean deleteIncome(int incomeId) throws SQLException {
        return incomeDAO.deleteIncome(incomeId);
    }

    public List<Income> getUserIncomes(int userId) throws SQLException {
        return incomeDAO.getIncomesByUserId(userId);
    }

    public List<Income> getUserIncomesByMonth(int userId, String monthYear) throws SQLException {
        return incomeDAO.getIncomesByUserIdAndMonth(userId, monthYear);
    }

    public BigDecimal getTotalIncomeByMonth(int userId, String monthYear) throws SQLException {
        return incomeDAO.getTotalIncomeByUserIdAndMonth(userId, monthYear);
    }

    public List<Object[]> getIncomeCategorySummary(int userId, String monthYear) throws SQLException {
        return incomeDAO.getIncomeCategorySummary(userId, monthYear);
    }
}